import UIKit
import PlaygroundSupport

print("------------ 在swift中创建一个线程(Thread) ------------")
PlaygroundPage.current.needsIndefiniteExecution = true
for i in 0..<10 {
    Thread.detachNewThread{
        print(i)
    }
}

print("------------ 初始化器创建thread ------------")
class ObjectThread {
    func threadTest () {
        let thread = Thread(target: self, selector: #selector(threadWorker), object: nil)
        thread.start()
    }
    
    @objc func threadWorker() {
        print("threadWorker")
    }
}
let obj = ObjectThread()
obj.threadTest()
